home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 1996 April / Software of the Month Club 1996 April.iso / pc / os2 / psutils / cmd / fixdls~1.cmd < prev    next >
Encoding:
Text File  |  1996-02-21  |  1.5 KB  |  57 lines

  1. extproc perl5 -x
  2. #! perl5
  3.  
  4. # fixdlsrps: fix DviLaser/PS document to work with PSUtils
  5. #
  6. # Copyright (C) Angus J. C. Duggan 1991-1995
  7. # See file LICENSE for details.
  8.  
  9. $nesting = 0;
  10. $page = 1;
  11. $infont = 0;
  12.  
  13. @fonts = ();
  14. @body = ();
  15. $header = 1;
  16.  
  17. while (<>) {
  18.    if (/^XP/) {
  19.       $infont++;
  20.       push(@fonts, $_);
  21.       $infont-- if /PXL.*RP/ || /DN?F.*RP/;
  22.    } elsif ($infont) {
  23.       push(@fonts, $_);
  24.       $infont-- if /PXL.*RP/ || /DN?F.*RP/;
  25.    } elsif ((/^%%EndSetup/ || /^%%Page:/) && $header) {
  26.       print @body;
  27.       @body = ("%%EndSetup\n");
  28.       $header = 0;
  29.    } elsif (/^%%EndProlog/ && !$nesting) {
  30.       push(@body,
  31.        "\$DviLaser begin/GlobalMode{}bdef/LocalMode{}bdef/XP{}def/RP{}def",
  32.        "/DoInitialScaling{72.0 Resolution div dup scale}bdef end\n", $_);
  33.    } elsif (/^%%BeginPageSetup/ && !$nesting) {
  34.       push(@body, "%%Page: $page $page\n", $_,
  35.         "Resolution 72 div dup scale Magnification 1000 div dup scale\n",
  36.         "/DocumentInitState where {\n",
  37.         "/DocumentInitState [ matrix currentmatrix currentlinewidth",
  38.         " currentlinecap currentlinejoin currentdash currentgray",
  39.         " currentmiterlimit] cvx put}if\n");
  40.       $page++;
  41.    } elsif (/^%%BeginDocument:/ || /^%%BeginBinary:/ || /^%%BeginFile:/) {
  42.       push(@body, $_);
  43.       $nesting++;
  44.    } elsif (/^%%EndDocument/ || /^%%EndBinary/ || /^%%EndFile/) {
  45.       push(@body, $_);
  46.       $nesting--;
  47.    } elsif (!/^%%PageBoundingBox:/ && !/^%%Page:/) {
  48.       push(@body, $_);
  49.    }
  50. }
  51.  
  52. print @fonts;
  53. print @body;
  54.  
  55. exit 0;
  56. # End of Script
  57.